#include	"GameService.h"
#include	"CenterConnector.h"

#include	<protocols/GS.pb.h>
#include	<protocols/Center.pb.h>

void GameService::OnClose(Sender * sender, ENet::Close reason) {

}

void GameService::OnReceive(Sender * sender, Protocol * msg) {

}

bool GameService::Initialize(const std::string & ip, int port) {
	_ip = ip, _port = port;
	return Listen(ip, port);
}

void GameService::Register() {
	Proto::CmdRegister cmd;
	cmd.set_type(Proto::ST_GS);
	cmd.mutable_addr()->set_ip(_ip);
	cmd.mutable_addr()->set_port(_port);
	GCenter.Send(Proto::CMD_REGISTER, cmd);
}